<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>种植政策</title>
  <link rel="stylesheet" href="../../../yl/index.css" />
  <!-- 布局样式 -->
  <link rel="stylesheet" href="../../../yl/style.css" />
  <link rel="stylesheet" href="../../../yl/mobile.css" />
  <link rel="stylesheet" href="../../../yl/easyui.css" />
  <link rel="stylesheet" href="../../../yl/icon.css" />
</head>

<body>
  <!-- <div id="app"> -->
  <div class="easyui-navpanel" id="app" v-cloak>
    <header>
      <div class="m-toolbar">
        <div class="m-title">{{action=='Add'?'增加种植政策信息':action=='Modify'?'查询种植政策信息':''}}</div>
      </div>
    </header>
    <div class="easyui-navpanel panel-body panel-body-nobottom panel-body-noborder" id="MainTable" ref="MainTable"
      :data-options="JSON.stringify({ 'TableName':'subsidy_policy', 'form': 'dataForm' ,'primary_key':'Policy_SerialNumber'})">
      <div class="yl-main">
        <div class="table_titel">
          <div class="titel">种植政策</div>
        </div>
        <el-form :model="dataForm" ref="form" :inline-message="true" style="width: 100%">
          <el-descriptions :column="1" size="large" border>
            <el-descriptions-item>
              <template #label>
                <div class="cell-item">政策名称</div>
              </template>
              <el-input :disabled="action == 'Modify'" v-model="dataForm.Policy_Name" class="borderless-input"
                placeholder="请输入政策名称" />
            </el-descriptions-item>
            <!-- <el-descriptions-item>
              <template #label>
                <div class="cell-item">政策类型</div>
              </template>
              <el-select clearable v-model.trim="dataForm.Policy_Type_SerialNumber" placeholder="请选择政策类型" filterable
                  style="width: 100%">
                  <el-option v-for="(item,index) in subsidy_policy_type" :key="index" :label="item.Policy_Type_Name"
                    :value="item.Policy_Type_SerialNumber"></el-option>
                </el-select>
            </el-descriptions-item> -->
            <!-- <el-descriptions-item>
              <template #label>
                <div class="cell-item">补贴金额</div>
              </template>
              <el-form-item prop="Subsidy_Amount"
                  :rules="[{ required: true, validator: validator1, trigger: 'blur' }]">
                  <el-input v-model="dataForm.Subsidy_Amount" class="borderless-input" placeholder="请输入补贴金额" />
              </el-form-item>
            </el-descriptions-item> -->
            <el-descriptions-item>
              <template #label>
                <div class="cell-item">生效日期</div>
              </template>
              <el-date-picker :disabled="action == 'Modify'" v-model="dataForm.Effective_Date" format="YYYY-MM-DD"
                value-format="YYYY-MM-DD" class="borderless-input" type="date" placeholder="请选择生效日期"
                size="large"></el-date-picker>
            </el-descriptions-item>
            <el-descriptions-item>
              <template #label>
                <div class="cell-item">失效日期</div>
              </template>
              <el-date-picker :disabled="action == 'Modify'" v-model="dataForm.Expiry_Date" format="YYYY-MM-DD"
                value-format="YYYY-MM-DD" class="borderless-input" type="date" placeholder="请选择失效日期"
                size="large"></el-date-picker>
            </el-descriptions-item>
            <el-descriptions-item>
              <template #label>
                <div class="cell-item">补贴条件</div>
              </template>
              <el-input type="textarea" :disabled="action == 'Modify'" :autosize="{ minRows: 5}" ref="grid_member"
                v-model="dataForm.Eligibility_Criteria" class="borderless-input" placeholder="请输入补贴条件" />
            </el-descriptions-item>
            <el-descriptions-item v-if="action == 'Add'">
              <template #label>
                <div class="cell-item">附件</div>
              </template>
              <yl-upload drag v-model="dataForm.Attachment_URL"></yl-upload>
            </el-descriptions-item>
          </el-descriptions>
        </el-form>

        <div id="ChildTable" v-if="dataForm.Policy_Type_SerialNumber!='SPT000000000002'">
          <div class="table_titel" v-if="action=='Modify'">
            <div class="titel">政策明细</div>
          </div>
          <el-table v-if="action=='Modify'" id="table" border max-height="450" tooltip-effect="dark"
            :data="[{Attachment_URL:dataForm.Attachment_URL}]">
            <el-table-column min-width="180" prop="Attachment_URL" label="附件名称"></el-table-column>
            <el-table-column width="200" fixed="right" align="center" label="操作">
              <template v-slot="{row}">
                <el-button type="primary" size="small" @click="preview(row)">
                  在线预览
                </el-button>
                <el-button type="success" size="small" @click="download(row)">
                  下载附件
                </el-button>
              </template>
            </el-table-column>
          </el-table>
          <div class="table_titel">
            <div class="titel">政策明细</div>
            <div class="operation">
              <el-button type="primary" v-if="action == 'Add'" size="small"
                @click="handleAdd('childDataForm')">新增</el-button>
              <el-button type="danger" v-if="action == 'Add'" size="small"
                @click="handleRemove('childDataForm')">删除</el-button>
            </div>
          </div>
          <el-form :model="{childDataForm:childDataForm.filter(item => item.Row_Status != '1')}" ref="form1"
            :inline-message="true" style="width: 100%">
            <el-descriptions
              :data-options="JSON.stringify({ 'TableName': 'subsidy_policy_detail', 'form': 'childDataForm', 'ParentTableName': 'subsidy_policy'})"
              :column="2" size="large" border
              v-for="(item,index) in childDataForm.filter(item => item.Row_Status != '1')" :key="index">
              <el-descriptions-item>
                <template #label>
                  <div class="cell-item">适用作物</div>
                </template>
                <el-form-item :prop="'childDataForm.'+index+'.Crop_SerialNumber'"
                  :rules="[{ required: true, message: '请选择适用作物', trigger: 'change' }]">
                  <el-select :disabled="action == 'Modify'" clearable v-model.trim="item.Crop_SerialNumber"
                    placeholder="请选择适用作物" filterable style="width: 100%">
                    <el-option v-for="(item,index) in crop" :key="index" :label="item.Crop_Name"
                      :value="item.Crop_SerialNumber"></el-option>
                  </el-select>
                </el-form-item>
              </el-descriptions-item>
              <el-descriptions-item>
                <template #label>
                  <div class="cell-item">补贴金额（元/亩）</div>
                </template>
                <el-form-item :prop="'childDataForm.'+index+'.Subsidy_Amount'"
                  :rules="[{ required: true, validator:validator, trigger: 'blur' }]">
                  <el-input :disabled="action == 'Modify'" type="number" v-model="item.Subsidy_Amount" class="borderless-input"
                    placeholder="请输入补贴金额（元/亩）" />
                </el-form-item>
              </el-descriptions-item>
              <el-descriptions-item>
                <template #label>
                  <div class="cell-item">生效日期</div>
                </template>
                <el-date-picker :disabled="action == 'Modify'" v-model="item.Effective_Date" format="YYYY-MM-DD"
                  value-format="YYYY-MM-DD" class="borderless-input" type="date" placeholder="请选择生效日期"
                  size="large"></el-date-picker>
              </el-descriptions-item>
              <el-descriptions-item>
                <template #label>
                  <div class="cell-item">失效日期</div>
                </template>
                <el-date-picker :disabled="action == 'Modify'" v-model="item.Expiry_Date" format="YYYY-MM-DD"
                  value-format="YYYY-MM-DD" class="borderless-input" type="date" placeholder="请选择失效日期"
                  size="large"></el-date-picker>
              </el-descriptions-item>
              <el-descriptions-item>
                <template #label>
                  <div class="cell-item">补贴条件</div>
                </template>
                <el-input type="textarea" :autosize="{ minRows: 5}" :disabled="action == 'Modify'" ref="grid_member" v-model="item.Eligibility_Criteria"
                  class="borderless-input" placeholder="请输入补贴条件" />
              </el-descriptions-item>
            </el-descriptions>
          </el-form>
        </div>
      </div>
      <yl-online-preview :file-url="fileUrl" v-model="showDialog"></yl-online-preview>
    </div>
    <footer class="botton-ann">
      <el-button @click="goBack">返回</el-button>
      <el-button v-if="action=='Add'" type="primary" plain @click="handleSubmit" :loading="loading">提交</el-button>
    </footer>
  </div>
</body>
<script src="../../../utils/utils.js"></script>
<script src="../../../config/config.js"></script>
<script src="../../../utils/mixins.js"></script>
<script src="../../../yl/vue.js"></script>
<script src="../../../yl/index.js"></script>
<script src="../../../yl/zh-cn.mjs"></script>
<script src="../../../yl/index.iife.min.js"></script>
<script src="../../../yl/jquery.min.js"></script>
<script src="../../../utils/jquery.cookie.js"></script>
<script src="../../../yl/jquery.easyui.min.js"></script>
<script src="../../../yl/jquery.easyui.mobile.js"></script>
<script src="../../../yl/moment.min.js"></script>
<script src="../../../api/request.js"></script>
<script src="./js/add.js"></script>

</html>